#pragma once
#include <boost/signals2.hpp>
#include <nice2d/entity.h>
#include <nice2d/imagedescriptor.h>

class Animation : public Entity
{
public:
    Animation();
    ~Animation();
public:
    void start();
    bool isStarted()const;

    void pause();
    bool isPaused()const;

    void clear();

    boost::signals2::signal<void()> finished;

    void setSingleShot(bool single = true);
    bool getSingleShot()const;

    void setDurationPerFrame(float duration = 200.0f);
    void setImageDescriptor(std::shared_ptr<ImageDescriptor> descriptor);
public:
    virtual PTree serialize() override;
    virtual void deserialize(const PTree &node) override;
protected:
    void onUpdateEntity(float deltaTime) override;
    void onDrawEntity(sf::RenderTarget &target, sf::RenderStates states) const override;
private:
    std::unique_ptr<class AnimationData> data;
};